package com.yungu.swift.socket.push.model;


import com.yungu.swift.utils.StringUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * PushContent
 *
 * @author cuixiuyin
 * @date 2018/12/15
 */
public class PushContent implements Serializable {

    /**
     * 推送对象 枚举类型
     */
    public enum To {
        //乘客
        PASSENGER,
        //司机
        DRIVER,
        //管理后台
        ADMIN
    }


    /**
     * 司机操作需要推送给乘客的操作码，包括：
     * 司机已接单 1000
     * 司机已出发 1001
     * 司机已到达接客地点，等待中 1002
     * 开始服务 1003
     * 到达目的地 1004
     * 司机变更位置 1005
     * 抢单成功 1006
     * 抢单失败 1007
     * 司机代支付成功 1008
     * 司机已接单_租车类型 1009
     * 司机取消订单 1009
     * 跨城订单匹配到 1010
     * 出租车司机确认费用 1011
     * 推送时时价格信息 1012
     * 推送时时价格信息 1013
     */
    public static final int ORDER_DRIVER_TAKE = 1000;
    public static final int ORDER_DRIVER_SET_OUT = 1001;
    public static final int ORDER_DRIVER_ARRIVE_PICK_UP_LOCATION = 1002;
    public static final int ORDER_DRIVER_START_SERVICE = 1003;
    public static final int ORDER_DRIVER_ARRIVE_DESTINATION = 1004;
    public static final int ORDER_DRIVER_UPD_LOCATION = 1005;
    public static final int ORDER_DRIVER_RUSH_ORDER_SUCCESS = 1006;
    public static final int ORDER_DRIVER_RUSH_ORDER_FAIL = 1007;
    public static final int ORDER_DRIVER_HELP_PAYED_SUCCESS = 1008;
    public static final int RENT_ORDER_DRIVER_TAKE = 1009;
    public static final int ORDER_DRIVER_CANCEL = 1009;
    public static final int ORDER_DRIVER_MATCH = 1010;
    public static final int ORDER_DRIVER_CONFIRM_FARE = 1011;
    public static final int ORDER_REALTIME_FARE = 1012;
    public static final int ORDER_DRIVER_RUSH_ORDER_GRAB = 1013;


    /**
     * 乘客操作需要推给司机的操作码，包括：
     * 可抢订单推送 2000
     * 订单派送 2001
     * 乘客取消订单 2002
     * 用户已支付 2003
     * 订单被改派 2004
     * 收到改派订单 2005
     * 乘客申请行程 2006
     * 跨城订单匹配到 2007
     * 跨城订单客服关闭乘客订单 2008
     * 跨城订单客服关闭司机订单 2008
     */
    public static final int ORDER_PUSH = 2000;
    public static final int ORDER_DISTRIBUTE = 2001;
    public static final int ORDER_PASSENGER_CANCEL = 2002;
    public static final int ORDER_PASSENGER_ORDER_PAYED = 2003;
    public static final int ORDER_DISTRIBUTE_TO_OTHER = 2004;
    public static final int ORDER_CHANGE_DISTRIBUTE = 2005;
    public static final int ORDER_SENDTASK_NEW_APPLY = 2006;
    public static final int ORDER_PASSENGER_MATCH = 2007;
    public static final int ORDER_PASSENGER_CLOSE = 2008;
    public static final int ORDER_DRIVER_CLOSE = 2008;

    /**
     * 后台自动流程的操作码，包括：
     * 后台取消订单 3000
     * 指定司机派送成功 3001
     * 指定司机派送失败 3002
     * 指定司机的订单后台取消 3003
     * 后台关闭订单 3004
     * 官网关闭订单 3005
     * 后台匹配超时，取消订单 3006
     * 后台调整订单金额 3007
     * 后台封禁司机账户 3100
     * 后台封号乘客登出 3020
     * 后台修改订单信息 3030
     */
    public static final int ORDER_ADMIN_CANCEL = 3000;
    public static final int ORDER_ADMIN_ASSIGN_SUCCESS = 3001;
    public static final int ORDER_ADMIN_ASSIGN_FAIL = 3002;
    public static final int ORDER_ADMIN_ASSIGN_CANCEL = 3003;
    public static final int ORDER_ADMIN_CLOSE = 3004;
    public static final int ORDER_ENT_CLOSE = 3005;
    public static final int ORDER_OVER_TIME_CANCEL = 3006;
    public static final int ORDER_ADJUST_FARE = 3007;
    public static final int ORDER_DRIVER_SEAL_ACCOUNT = 3100;
    public static final int ORDER_ADMIN_PASSENGER_LOGOUT = 3020;
    public static final int ORDER_ADMIN_EDIT_INFO = 3030;

    /**
     * ORDER_JOIN_PAS_SUBING = 2110;//跨城拼车：预约中
     * ORDER_JOIN_PAS_SUB_SUCCESS = 2120;//跨城拼车：预约成功
     * ORDER_JOIN_PAS_ASSIGNED = 2125;//跨城拼车：派单完成
     * ORDER_JOIN_DRI_ASSIGNED = 2130;//跨城拼车：收到派单
     * ORDER_JOIN_PAS_CHANGE_ASSIGNED = 2131;//跨城拼车：乘客-订单被改派
     * ORDER_JOIN_DRI_OLD_CHANGE_ASSIGNED = 2132;//跨城拼车：原司机-订单被改派
     * ORDER_JOIN_DRI_NEW_CHANGE_ASSIGNED = 2133;//跨城拼车：新司机-收到改派订单
     * ORDER_JOIN_DRI_NEW_MARGE_ASSIGNED = 2134;//跨城拼车：司机-收到合并派单订单
     * ORDER_JOIN_DRI_QUIT_QUEUE = 2140;//跨城拼车：退出线路排队
     * ORDER_JOIN_PAS_ORDER_DRIVER_DEPARTURE = 2141;//跨城拼车：行程开始（去接乘客）
     * ORDER_JOIN_PAS_ORDER_ARRIVE_POINT = 2142;//跨城拼车：司机到达上车点
     * ORDER_JOIN_PAS_ORDER_ABOARD = 2143;//跨城拼车：乘客已上车
     * ORDER_JOIN_PAS_ORDER_STARTED = 2144;//跨城拼车：行程中（出发前往目的地）
     * ORDER_JOIN_PAS_ORDER_COMPLETE = 2145;//跨城拼车：行程结束（订单完成-预留）
     * ORDER_JOIN_PAS_ORDER_WAIT_DRIVER_PAY = 2146;//跨城拼车：司机收现
     * ORDER_JOIN_PAS_ORDER_WAIT_PAS_PAY = 2147;//跨城拼车：发送账单给乘客支付
     * ORDER_JOIN_PAS_ORDER_COMMENT = 2148;//跨城拼车：乘客评价订单行程（预留）
     * ORDER_JOIN_PAS_ORDER_REFRESH = 2149;//跨城拼车：乘客刷新订单
     * ORDER_JOIN_CLOSE_ORDER = 2150;//跨城拼车：关闭订单
     * ORDER_JOIN_REFUND = 2160;//跨城拼车：订单退款请求已受理
     * ORDER_JOIN_REFUND_SUCCESS = 2170;//跨城拼车：订单退款成功
     * ORDER_JOIN_ORDER_TIME = 2180;//跨城拼车：订单时间提醒
     */
    public static final int ORDER_JOIN_PAS_SUBING = 2110;
    public static final int ORDER_JOIN_PAS_SUB_SUCCESS = 2120;
    public static final int ORDER_JOIN_PAS_ASSIGNED = 2125;
    public static final int ORDER_JOIN_DRI_ASSIGNED = 2130;
    public static final int ORDER_JOIN_PAS_CHANGE_ASSIGNED = 2131;
    public static final int ORDER_JOIN_DRI_OLD_CHANGE_ASSIGNED = 2132;
    public static final int ORDER_JOIN_DRI_NEW_CHANGE_ASSIGNED = 2133;
    public static final int ORDER_JOIN_DRI_NEW_MARGE_ASSIGNED = 2134;
    public static final int ORDER_JOIN_DRI_QUIT_QUEUE = 2140;
    public static final int ORDER_JOIN_PAS_ORDER_DRIVER_DEPARTURE = 2141;
    public static final int ORDER_JOIN_PAS_ORDER_ARRIVE_POINT = 2142;
    public static final int ORDER_JOIN_PAS_ORDER_ABOARD = 2143;
    public static final int ORDER_JOIN_PAS_ORDER_STARTED = 2144;
    public static final int ORDER_JOIN_PAS_ORDER_COMPLETE = 2145;
    public static final int ORDER_JOIN_PAS_ORDER_WAIT_DRIVER_PAY = 2146;
    public static final int ORDER_JOIN_PAS_ORDER_WAIT_PAS_PAY = 2147;
    public static final int ORDER_JOIN_PAS_ORDER_COMMENT = 2148;
    public static final int ORDER_JOIN_PAS_ORDER_REFRESH = 2149;
    public static final int ORDER_JOIN_CLOSE_ORDER = 2150;
    public static final int ORDER_JOIN_REFUND = 2160;
    public static final int ORDER_JOIN_REFUND_SUCCESS = 2170;
    public static final int ORDER_JOIN_ORDER_TIME = 2180;

    /**
     * 跨城拼车
     * 新增跨城订单提醒
     * 新增跨城订单通话
     */
    public static final int NEW_JOIN_ORDER_TIP = 10100;
    public static final int NEW_JOIN_ORDER_CALL = 10101;

    /**
     * 提醒类推送，包括：
     * 待服务订单通知 4000
     * 航班变动通知 5000
     */
    public static final int ORDER_WAIT_SERVICE_NOTICE = 4000;
    public static final int ORDER_FLIGHT_CHANGE_NOTICE = 5000;

    /**
     * 其他通知类型，包括：
     * 其他通知推送 6000
     * 系统消息推送 6001
     * 报警消息推送 6002
     */
    public static final int OTHER_NOTICE = 6000;
    public static final int SYSTEM_MESSAGE_NOTICE = 6001;
    public static final int ALARM_MESSAGE_NOTICE = 6002;



    /**
     * 成员变量，包括：
     * 推送消息ID  pushUuid
     * 推送对象 to
     * appId appId
     * 操作码（用以验证并判断本次推送具体的操作内容） opCode
     * 是否需要极光推送，true是，false否 needJPush
     * 附加数据(title,content,extras) data
     * 创建时间 createTime
     * 重复次数 retry
     */
    private String pushUuid = StringUtils.buildUUID();
    private To to;
    private String appid;
    private int opCode;
    private boolean needJPush;
    private Map<String, Object> data;
    private Date createTime = new Date();
    private int retry = 0;

    //长连接集群标识缓存前缀
    public static String SOCKET_CLUSTER_PREFIX = "CLUSTER_";


    public PushContent(To to, String appid, int opCode, boolean needJPush, Map<String, Object> data) {
        this.to = to;
        this.appid = appid;
        this.opCode = opCode;
        this.needJPush = needJPush;
        this.data = data;
    }

    public String getPushUuid() {
        return pushUuid;
    }

    public void setPushUuid(String pushUuid) {
        this.pushUuid = pushUuid;
    }

    public To getTo() {
        return to;
    }

    public void setTo(To to) {
        this.to = to;
    }

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public int getOpCode() {
        return opCode;
    }

    public void setOpCode(int opCode) {
        this.opCode = opCode;
    }

    public boolean isNeedJPush() {
        return needJPush;
    }

    public void setNeedJPush(boolean needJPush) {
        this.needJPush = needJPush;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public int getRetry() {
        return retry;
    }

    public void setRetry(int retry) {
        this.retry = retry;
    }

    /**
     * 实例化推送内容【乘客】
     *
     * @param appid
     * @param opCode
     * @param data
     * @return
     */
    public static PushContent newInstance4Pas(String appid, int opCode, Map<String, Object> data) {
        return new PushContent(To.PASSENGER, appid, opCode, false, data);
    }

    /**
     * 实例化推送内容【司机】
     *
     * @param appid
     * @param opCode
     * @param data
     * @return
     */
    public static PushContent newInstance4Dri(String appid, int opCode, Map<String, Object> data) {
        return new PushContent(To.DRIVER, appid, opCode, false, data);
    }


    /**
     * 实例化推送内容【管理后台】
     *
     * @param appId
     * @param opCode
     * @param data
     * @return
     */
    public static PushContent newInstance4Admin(String appId, int opCode, Map<String, Object> data) {
        return new PushContent(To.ADMIN, appId, opCode, false, data);
    }

    /**
     * 实例化推送内容，包括极光推送【乘客】
     *
     * @param appId
     * @param opCode
     * @param data
     * @return
     */
    public static PushContent newInstance4PasWithJPush(String appId, int opCode, Map<String, Object> data) {
        return new PushContent(To.PASSENGER, appId, opCode, true, data);
    }

    /**
     * 实例化推送内容，包括极光推送【司机】
     *
     * @param appId
     * @param opCode
     * @param data
     * @return
     */
    public static PushContent newInstance4DriWithJPush(String appId, int opCode, Map<String, Object> data) {
        return new PushContent(To.DRIVER, appId, opCode, true, data);
    }


}
